package org.jtzc.langchang4jdemo;

import dev.langchain4j.data.message.UserMessage;
import dev.langchain4j.model.chat.request.ChatRequest;
import dev.langchain4j.model.chat.request.ChatRequestParameters;
import dev.langchain4j.model.chat.response.ChatResponse;
import dev.langchain4j.model.openai.OpenAiChatModel;

/**
 * @author wu chuang
 * @description
 */
public class Demo1 {

    public static void main(String[] args) {
        OpenAiChatModel model = OpenAiChatModel.builder()
                .baseUrl("http://langchain4j.dev/demo/openai/v1")
                .apiKey("demo") //设置模型apiKey
                .modelName("gpt-4o-mini") //设置模型名称
                .build();

        //向模型提问
//        String answer = model.chat("请问今天是星期几?什么时候放假?");
        //输出结果
//        System.out.println(answer);
//        answer = model.chat("请重复");
//        System.out.println(answer);

        System.out.println(model.chat("你好，我是小矩"));
        System.out.println("----");
        System.out.println(model.chat("我叫什么"));


//        ChatRequest chatRequest = ChatRequest.builder()
//                .messages(...)
//                .modelName(...)
//                .temperature(...)
//                .topP(...)
//                .topK(...)
//                .frequencyPenalty(...)
//                .presencePenalty(...)
//                .maxOutputTokens(...)
//                .stopSequences(...)
//                .toolSpecifications(...)
//                .toolChoice(...)
//                .responseFormat(...)
//                .parameters(...) // you can also set common or provider-specific parameters all at once
//                .build();
//
//        ChatResponse chatResponse = chatModel.chat(chatRequest);
//                model.chat();


        UserMessage userMessage = new UserMessage("你好");
        ChatRequestParameters chatRequestParameters = ChatRequestParameters.builder()
                .modelName("")
                .temperature(0.7)
                .frequencyPenalty(1d)
                .build();
        ChatRequest request = ChatRequest.builder().messages(userMessage).parameters(chatRequestParameters).build();
        model.chat(request);
    }
}
